package coml.jiyun.hp.animation;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.os.Bundle;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    private ImageView mImg;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();
    }

    private void initView() {
        mImg = (ImageView) findViewById(R.id.img);

        //属性动画
        ObjectAnimator alpha = ObjectAnimator.ofFloat(mImg, "alpha", 3f, 1f);//渐变
        ObjectAnimator rotation = ObjectAnimator.ofFloat(mImg, "rotation", 0f, 720f);//旋转
        ObjectAnimator scaleX = ObjectAnimator.ofFloat(mImg, "scaleX", 1f, 2.5f);//缩放
        ObjectAnimator translationX = ObjectAnimator.ofFloat(mImg, "translationX", 1f, 100f);//平移

        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playSequentially(alpha,rotation,scaleX,translationX);
        animatorSet.setDuration(7000);
        animatorSet.start();
    }
}